<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>添加银行卡</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
	</head>
	<link rel="stylesheet" href="/zc/css/style.css" />
	<link rel="stylesheet" href="/zc/css/index.css" />
	<link rel="stylesheet" href="/zc/css/login.css" />
	<link rel="stylesheet" href="/zc/css/center_wddd.css" />
	<link rel="stylesheet" href="/zc/css/center_gywm.css" />
	<link href="/zc/css/footer.css" rel="stylesheet">
	<link rel="stylesheet" href="/zc/css/center_aqzx.css" />
	<script src="/zc/js/flexible.js"></script>
	<script src="/zc/js/flexible_css.js"></script>
	<script src="/zc/js/template.js"></script>
	<script src="/zc/js/jquery.min.js"></script>
	<script src="/zc/js/unslider.min.js"></script>
	<script src="/zc/js/foot_bar.js"></script>
	<script src="/zc/js/layer.js"></script>
	<style>
		html,body{
			background: #f1f1f1;
		}
		.yhkxx{
			width: 100%;
			color: #999;
			margin-top: .3rem;
		}
		.yhkxx p{
			width: 95%;
			margin: auto;
			font-size: .4rem;
			color: #333;
			line-height: .8rem;
		}
		.yhkxx_kk{
			width:100%;
			height: 1rem;
			background: #fff;
		}
		.yhkxx_kk input{
			width: 95%;
			display: block;
			margin: auto;
			height: 1rem;
			line-height: 1rem;
			border: 0;
			background: #fff;
			color: #333;
			font-size: .35rem;
		}
		.tj{
			width: 100%;
			height: 1rem;
			text-align: center;
			margin-top: 1rem;
		}
		.tj button{
			width: 80%;
			height: 1rem;
			border: 1px solid #18C78D;
			background: #18C78D;
			font-size: .4rem;
			color: #fff;
			line-height: 1rem;
			border-radius: .2rem;
		}
		.yhkxx_kk{
			width:100%;
			height: 1rem;
			background: #fff;
		}
		.yhkxx_kk input{
			width: 95%;
			display: block;
			margin: auto;
			height: 1rem;
			line-height: 1rem;
			border: 0;
			background: #fff;
			color: #333;
			font-size: .35rem;
		}
		.tj{
			width: 100%;
			height: 1rem;
			text-align: center;
			margin-top: 1rem;
		}
		.tj button{
			width: 80%;
			height: 1rem;
			border: 1px solid #18C78D;
			background: #18C78D;
			font-size: .4rem;
			color: #fff;
			line-height: 1rem;
			border-radius: .2rem;
		}
		.yzmbox{
			width: 100%;
			height: 1rem;
			overflow: hidden;
			background: #fff;
		}
		.yzm_lt,.yzm_rt{
			float: left;
		}
		.yzm_lt{
			width: 70%;
			height: 1rem;
		}
		.yzm_lt input{
			border: 0;
			line-height: 1rem;
			border: 0;
			background: #fff;
			color: #333;
			font-size: .35rem;
			margin-left: .3rem;
		}
		.yzm_rt{
			width: 30%;
			height: 1rem;
			float: right;
		}
		.yzm_rt button{
			width: 100%;
			height: 1rem;
			line-height: 1rem;
			background: #fff;
			border: 0;
			font-size: .4rem;
			color: #18C78D;
		}
	</style>
	<body>
		<div class="header">
			<span>添加银行卡</span>
			<a href="javascript:history.go(-1)" class="return"></a>
		</div>
		<div style="height: 1rem;"></div>
		
		<div class="yhkxx">
			<p>请输入银行卡类型</p>
			<div class="yhkxx_kk"><input class="srk" id="bank_name" type="text" placeholder="请输入所属银行" /></div>
		</div>
		<div class="yhkxx">
			<p>请输入所属支行</p>
			<div class="yhkxx_kk"><input class="srk" id="bank_open" type="text" placeholder="请输入所属支行" /></div>
		</div>
		<div class="yhkxx">
			<p>请输入卡号</p>
			<div class="yhkxx_kk"><input class="srk" id="bank_number" type="number" placeholder="请输入银行卡号" /></div>
		</div>
		
		<div class="yhkxx">
			<p>请输入姓名</p>
			<div class="yhkxx_kk"><input class="srk" id="realname" type="text" placeholder="请输入持卡人姓名" /></div>
		</div>
		
		<!-- <div class="yhkxx">
			<p>请输入电话</p>
			<div class="yhkxx_kk"><input class="srk" type="number" placeholder="请输入银行预留手机号" /></div>
		</div>
		 -->
		<div class="yhkxx">
			<p>请输入密码</p>
			<div class="yhkxx_kk"><input autocomplete="off" class="srk" id="trad_password" type="password" placeholder="请输入支付密码" /></div>
		</div>
		
		<div class="yhkxx">
			<p>验证码</p>
			<div class="yzmbox">
				<div class="yzm_lt"><input autocomplete="off" id="yzm" class="srk" type="text" placeholder="请输入验证码" /></div>
				<div class="yzm_rt" ><button class="get_code">获取验证码</button></div>
			</div>		
		</div>
		
		<div class="tj"><button type="submit">添加</button></div>
	</body>
	
</html>
<script type="text/javascript">
	function getQueryString(name) {   
   var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
   var r = window.location.search.substr(1).match(reg);
   if (r != null) return unescape(r[2]); return null;
  }
  var id = getQueryString("id");
  console.log(id)
	$('.get_code').click(function (e) { 
		var that = $(this);
			$.ajax({
				type: "POST",
				url: "/index/otcexchange/sendcode",
				dataType: "jsonp",
				success: function (res) {
					if (res.code=='0') {
					that.html('60s').attr('disabled', true);
					var timer = setInterval(function(){
						var num = parseInt(that.text());
						if (num <= 1) {
							that.html('重新发送').removeAttr('disabled');
							clearInterval(timer);
						} else {
							that.html(--num+'s');
						}
					}, 1000);
				}
				//alert(res.msg);
				layer.open({content:res.msg,skin: 'msg',
				                time: 2
				            });
				}
			});
	});
	$('.tj').click(function(){
		
		var trad_password = $('#trad_password').val();
		var realname = $('#realname').val();
		// var types = $('#types').val();
		var types = 1;
		var bank_name = $('#bank_name').val();
		var bank_open = $('#bank_open').val();
		var bank_number = $('#bank_number').val();
		var code=$('#yzm').val();
		// alert(bank_open)
		// return;
		$.ajax({
	        type: "POST",
	        data: {code:code,trad_password:trad_password,realname:realname,types:id,bank_name:bank_name,bank_open:bank_open,bank_number:bank_number},
	        dataType: "json",
	        url: "/index/usercenter/addaccount",
	        success: function (res) {
	        	console.log(res)
	            if(res.code==0){
	            	//alert('添加成功');
					layer.open({content:'添加成功',skin: 'msg',
				                time: 2
				            });
					window.location.href='/index/member/center_yhkgl';
	            }else{
					//alert(res.msg)
					layer.open({content:res.msg,skin: 'msg',
				                time: 2
				            });
	            }
	        }
	    });
	})
</script>